package org.zoomdev.zoom.dao.adapters.result;

import org.zoomdev.zoom.dao.adapters.ResultSetAdapter;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.time.Instant;

public class Timestamp2InstantResultSetAdapter implements ResultSetAdapter<Instant> {
    @Override
    public Instant getObject(ResultSet rs, int index) throws SQLException {
        Timestamp time = rs.getTimestamp(index);
        if (time == null) {
            return null;
        }
        return time.toInstant();
    }
}